﻿using FishServe.Core.Services.UpdaterService;
using FishServe.Core.Services.UpdaterService.Common;
using FishServe.Core.Services.UpdaterService.Interfaces;
using NUnit.Framework;
using FishServe.Core;
using System.IO;
using System.Security.Cryptography;
using System;


namespace Test.FishServe.Core.Services.UpdaterService
{
	[TestFixture]
	public class ReleaseManifestReaderFixture
	{
		//public const string MANIFEST_FILE_PATH = @"C:\Documents and Settings\hoon\Desktop\info.xml";
		public const string MANIFEST_FILE_PATH = @"C:\WorkDir\CEEDT\2008-12-31\Deployment\FishServe.Client.Solution.1.3.manifest";

		private IReleaseManifestService releaseManifestService = new ReleaseManifestService();

		[Test]
		public void ValidateApplicationModuleManifest()
		{
			ReleaseManifest releaseManifest
				= releaseManifestService.RetrieveReleaseManifestFrom(MANIFEST_FILE_PATH);
			

			ModuleManifest moduleManifest = releaseManifest.ModuleManifests[0];

			Assert.IsTrue(moduleManifest.DependentModules.Count == 4, "Expecting four dependant/child modules");
			Assert.IsTrue(moduleManifest.ManifestType.Equals(ModuleManifestType.Application));
			Assert.IsTrue(moduleManifest.IncludeFiles.Count == 1, "Expecting");

			Assert.IsNotNull(moduleManifest.Module.FileHash, "Expecting to read in a FileHash value from manifest file.");



			Console.WriteLine("releaseManifest.FileName: " + releaseManifest.Filename);
		}

		[Test]
		public void foo()
		{
			FileInfo fi = new FileInfo(@"C:\WorkDir\CEEDT\2008-12-31\Deployment\Modules\FishServe.Core\1.0.3299.20224\FishServe.Core.dll");
			HashAlgorithm algo = new SHA256Managed();

			Console.WriteLine(fi.ComputeFileHash(algo));
		}

	}
}
